package main

import (
	"server/core"
	"server/global"
	"server/initialize"
	sysService "server/service/system"
)

//go:generate go env -w GO111MODULE=on
//go:generate go env -w GOPROXY=https://goproxy.cn,direct
//go:generate go mod tidy
//go:generate go mod download

// @title Swagger Example API
// @version 0.0.1
// @description This is a sample Server pets
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name x-token
// @BasePath /
func main() {
	global.GvaVp = core.Viper()      // 初始化Viper
	global.GvaLog = core.Zap()       // 初始化zap日志库
	global.GvaDb = initialize.Gorm() // gorm连接数据库
	// 初始化redis服务
	initialize.Redis()
	//初始化验证类
	initialize.Validator()
	//初始化定时器
	initialize.Timer()
	if global.GvaDb != nil {
		//initialize.MysqlTables(global.GvaDb) // 初始化表
		if global.GvaConfig.System.IsInitDatabase {
			sysService.InitDatabase()
		}
		// 程序结束前关闭数据库链接
		db, _ := global.GvaDb.DB()
		defer db.Close()
	}
	core.RunWindowsServer()

}
